package 链表;

/**
 * https://leetcode-cn.com/problems/reverse-linked-list/
 *
 * @author Mxb
 * @version 1.0
 * @date 2020/2/23 22:01
 */
public class _206_反转链表 {

    public ListNode reverseList(ListNode head) {
        // 创建一个新的节点
        ListNode newHead = null;

        ListNode tmp = head.next;
        while (head != null) {
            //1，head-> newhead
            head.next = newHead;
            newHead = head;
            head = tmp;
        }
        return newHead;
    }
}
